package 原型模式.demo.复制简历;

/**
 * @author zyl
 * @Description
 * @since 2024/1/3 16:22
 */

public class Resume implements Cloneable{

    private String name;
    private String sex;
    private String age;
    private WorkExperience workExperience;

    public Resume(String name, String sex, String age, WorkExperience workExperience) {
        this.name = name;
        this.sex = sex;
        this.age = age;
        this.workExperience = workExperience;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public void setAge(String age) {
        this.age = age;
    }

    public void setWorkExperience(String timeArea, String company) {
        this.workExperience.setTimeArea(timeArea);
        this.workExperience.setCompany(company);
    }

    public void display(){
        System.out.println( this.name +" "+this.sex +""+this.age);
        System.out.println("工作经历"+ this.workExperience.getCompany() + this.workExperience.getTimeArea());
    }


    public Object clone(){
        Resume object = null;
        try {
            object = (Resume)super.clone();
            //深复制
            object.workExperience = (WorkExperience) this.workExperience.clone();
        }catch (CloneNotSupportedException e){
            System.out.println("克隆异常," + e.toString());
        }
        return object;
    }
}
